package forum.command;

import forum.entities.User;
import forum.services.UserService;

import java.math.BigInteger;

public class CreateCategoryCommand implements Command {

    private String categoryName;
    private BigInteger currentCategoryId;
    private User user;

    private UserService userService = new UserService();

    @Override
    public void execute() {
        userService.createCategory(user, currentCategoryId, categoryName);
    }

    @Override
    public void setParameters(String... args) {
        if (args.length != 1) {
            throw new IllegalArgumentException ("Incorrect number of arguments");
        }
        categoryName = args[0];
    }

    @Override
    public void setContext(CommandContext context) {
        currentCategoryId = context.getCategory().getId();
        user = context.getUser();
    }

    @Override
    public void updateContext(CommandContext context) {

    }

    @Override
    public String help() {
        return "Type new_cat | %category name%";
    }
}
